package com.md.rps.action.actions;

import com.md.rps.mybatis.model.HOSPITAL;
import com.md.rps.service.HospitalOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HospitalAction {
    @Autowired
    private HospitalOperator hospitalOperator;

    @GetMapping("getHospitalList")
    public List<HOSPITAL> getHospitalList(@RequestParam("start") int start,
                                          @RequestParam("end") int end){
        return hospitalOperator.getHospitalList(start,end);
    }

    @PostMapping("addHospital")
    public int addHospital(HOSPITAL hospital){
        return hospitalOperator.addHospital(hospital);
    }

    @PostMapping("updateHospital")
    public int updateHospital(HOSPITAL hospital){
        return hospitalOperator.updateHospital(hospital);
    }

    @PostMapping("deleteHospital")
    public int deleteHospital(@RequestParam("hosId") int id){
        return hospitalOperator.deleteHospital(id);
    }
}
